// @flow
import React, { Component } from 'react'
import AgGrid from 'components/AgGrid'
import moment from 'moment'
type Props = {
  data: Array<Object>
}

type States = {
  columnDefs: Array<Object>
}
class FinalList extends Component {
  props: Props
  state: States
  constructor (props: Props) {
    super(props)
    this.state = {
      columnDefs: [
        {
          headerName: '设备编号',
          field: 'deviceno',
          cellStyle: {
            padding: '8px'
          }
        },
        {
          headerName: '信息',
          field: 'message',
          cellStyle: {
            padding: '8px'
          }
        },
        {
          headerName: '级别',
          field: 'level',
          cellStyle: {
            padding: '8px'
          }
        },
        {
          headerName: '预警类型',
          field: 'warningtype',
          cellStyle: {
            padding: '8px'
          }
        },
        {
          headerName: '预警时间',
          field: 'ts',
          cellStyle: {
            padding: '8px'
          },
          cellRenderer: (params) => {
            return moment(params.data.operationDate).format('YYYY-MM-DD')
          }
        }
      ]
    }
  }
  render () {
    const { columnDefs } = this.state
    const { data } = this.props
    return <AgGrid {...{
      columnDefs,
      rowData: data
    }} />
  }
}

export default FinalList
